#include "UartProtocol.h"

UartProtocol::UartProtocol()
	: Protocol()
{
	errorCheck = false;
	parityCheck = true;
	uart = SoftwareUart();
}
UartProtocol::UartProtocol(SoftwareUart& u)
	: Protocol()
{
	uart = u;
	errorCheck = false;
	parityCheck = true;
}
void UartProtocol::config(){}

bool UartProtocol::error(){return errorCheck;}

bool UartProtocol::parity(){return parityCheck;}

void UartProtocol::run()
{
	if(uart.getFinished() == true)
	{
		//get the output.
		unsigned char out;
		bool par;
		out = uart.get(par);
		//ignore parity for right now no idea how to do more with it.
		this->setOutput(out);
		//now get next input.
		if(this->inputEmpty()==true)
		{
			unsigned char in = getInput();
			uart.set(in);
		}
	}
	//now do a run.
	uart.run();
}

